#ifndef VIEW_H
#define VIEW_H

#include <vector>
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <cmath>

#include "coordinate.h"
#include "color.h"
#include "scene.h"

const int SAMPLE_NUM = 4;

class View;

struct SliceData
{
  View *view;
  unsigned int minX, maxX;
};

class View
{
  public:
    View(Scene *scene);
    ~View();
    void loadAttributes(std::istream  &inData);
    void render();
    void saveHtml(std::ostream &outData);
    void savePpm(std::ostream &outData);
  private:
    static void* m_renderSliceThreadHook(void *threadData);
    void m_renderSlice(unsigned int minX, unsigned int maxX);
    Color m_sample(Ray r, int n);
    Scene *m_scene;
    Color *m_image;
    unsigned int m_width, m_height;
    Coordinate m_pos;
    double m_xRot, m_yRot, m_hFov, m_vFov;    
};

#endif

